package com.jt.provider.controller;

import com.alibaba.csp.sentinel.adapter.spring.webmvc.callback.RequestOriginParser;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component;

import javax.servlet.http.HttpServletRequest;
@Slf4j
@Component
public class DefaultRequestOriginParser implements RequestOriginParser {
    /**
     * 当设置了授权规则后，系统底层拦截到请求，会调用此方法，对请求数据进行解析
     * @param httpServletRequest
     * @return
     */
    @Override
    public String parseOrigin(HttpServletRequest request) {
        //String origin = request.getParameter("origin");

        String ip = request.getRemoteAddr();
        log.info("ip is "+ip);
        return ip;
    }
}
